﻿using HuaCheng.Model;

namespace HuaCheng.Controller
{
    /// <summary>
    /// 计算校准k、b值类
    /// </summary>
    public class CalibrateControl
    {
        /// <summary>
        /// 计算控制指令k,b值
        /// </summary>
        public void CalCalibrateControl(Factor factor, CalibrateSourceData sourceData1, CalibrateSourceData sourceData2)
        {
            //控制K
            factor.Controlk = (sourceData1.SetValue - sourceData2.SetValue) / (sourceData1.MeasureValue - sourceData2.MeasureValue);
            //控制b
            factor.Controlb = sourceData1.SetValue - factor.Controlk * sourceData1.MeasureValue;
        }
        /// <summary>
        /// 计算显示k、b值
        /// </summary>
        public void CalCalibrateShow(Factor factor, CalibrateSourceData sourceData1, CalibrateSourceData sourceData2)
        {
            //显示k
            factor.Showk = (sourceData1.MeasureValue - sourceData2.MeasureValue) / (sourceData1.ShowValue - sourceData2.ShowValue);
            //显示b
            factor.Showb = sourceData1.MeasureValue - factor.Showk * sourceData1.ShowValue;
        }
    }
}
